<template>
  <svg :class="svgClass" >
    <use :xlink:href="iconName" :fill="iconColor"/>
  </svg>
</template>

<script>

export default {
  name: "SvgIcon",
  props: {
    iconClass: {
      type: String,
      required: true
    },
    className: {
      type: String,
      default: ""
    },
    iconColor: {
      type: String,
      default: ""
    }
  },
  computed: {
    iconName() {
      return `#icon-${this.iconClass}`;  //跟svg-sprite-loader 生成的symbolId相对应上
    },
    svgClass() {
      if (this.className) {
        return "svg-icon " + this.className;  //自定义样式
      } else {
        return "svg-icon"; //默认样式
      }
    }
  },
};
</script>

<style scoped>
.svg-icon {
  width: 100%;
  height: 498px;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
  color: #fff;
}
</style>